pub fn add(left: usize, right: usize) -> usize {
    left + right
}

pub fn ad_two(a: i32) -> i32 {
    a + 3
}
pub fn greeting (name: &str) -> String {
    format!("Hello {}",name)
}

pub struct Guess {
    value: u32,
}

impl Guess {
    pub fn new(value: u32) -> Guess {
        if value < 1 {
            panic!("Guess value must be > 1, got {}.", value)
        } else if value > 100 {
            panic!("Guess value must be < 100, got {}.", value)
        }

        Guess {value}
    }
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn it_works() {
        let result = add(2, 2);
        assert_eq!(result, 4);
    }

    #[test]
    fn it_works_panic() {
        panic!("it don't work.")
    }

    #[test]
    #[ignore]
    fn it_works_two() {
        assert_eq!(4, ad_two(2))
    }

    #[test]
    fn greeting_contain_name() {
        let result = greeting("Carol");
        assert!(result.contains("Carols"),"Greeting didn't contain name,value was '{}'",result);
    }

    #[test]
    #[should_panic(expected = "guess value must be less than or equal to 100")]
    fn greater_than_100() {
        Guess::new(200);
    }
}
